package com.awspaas.user.apps.processforsap.event;

import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.bpmn.engine.core.delegate.ProcessExecutionContext;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListener;
import com.actionsoft.bpms.bpmn.engine.listener.ExecuteListenerInterface;
import com.actionsoft.sdk.local.SDK;

import java.util.List;

/**
 * 初始数据，给接口赋值
 */
public class InitialDataForMM002 extends ExecuteListener implements ExecuteListenerInterface {
    @Override
    public void execute(ProcessExecutionContext ctx) throws Exception {
        List<BO> list = SDK.getBOAPI().query("BO_EU_SAP_MM002_LIST").bindId(ctx.getProcessInstance().getId()).list();
        String [] companyS = {"FH00","FS00","YJ00"};
        if (list==null || list.size() ==0){
            for (int i=0;i<companyS.length;i++){
                String company = companyS[i];
                BO bo11 = new BO();
                bo11.set("BUKRS",company);
//                if (i==0){
//                    bo11.set("ZYWLX","1");
//                }else{
//                    bo11.set("ZYWLX","2");
//                }
                SDK.getBOAPI().create("BO_EU_SAP_MM002_LIST",bo11,ctx.getProcessInstance().getId(),ctx.getUserContext().getUID());
            }
        }
    }
}
